
<template>
  <a-table :columns="columns" :data-source="data">

  <span slot="action" slot-scope="text, record">
      <a-popconfirm
          title="您确定要删除当前感谢信?"
          ok-text="Yes"
          cancel-text="No"
          @confirm="deleteThank(record.id)"
          @cancel="()=>{}"
      >
    <a>删除感谢信</a>

  </a-popconfirm>

    </span>
  </a-table>
</template>

<script>
import { message } from 'ant-design-vue';
const columns = [
  {
    title:"发布者",
    dataIndex: 'createUserName',
    key: 'createUserName',

  },
  {
    title:"内容",
    dataIndex: 'text',
    key: 'text',
    ellipsis:true
  },
  {
    title: '操作',
    key: 'action',
    scopedSlots: { customRender: 'action' },
  },
];




export default ({
  data() {
    return {
      data:[],
      columns,
    }
  },
  beforeCreate() {


    this.$http({
      method: 'get',
      url: 'http://localhost:18082/thank/getall',
      data: {},
      headers:{
        user:localStorage.getItem("user"),
      }
    }).then((e)=>{

      this.data=e.data.data;
      console.log("查看当前事项",e);

    })

  },
  mounted() {

  },
  methods: {

    deleteThank(e){

      this.$http({
        method: 'delete',
        url: 'http://localhost:18082/thank/deletethank',
        data: {
          id:e
        },
        headers:{
          user:localStorage.getItem("user"),
        }
      }).then((e)=>{

        if(e.data.status){

          message.info("删除成功！",3);
          this.$http({
            method: 'get',
            url: 'http://localhost:18082/thank/getall',
            data: {},
            headers:{
              user:localStorage.getItem("user"),
            }
          }).then((e)=>{

            this.data=e.data.data;
            console.log("查看当前事项",e);

          })

        }else{

          message.error("删除失败！",3);

        }


      })

    }

  },
})

</script>

